
include_once Q_PATH & "\includes\ui\workspaceui.vbs"
include_once Q_PATH & "\includes\ui\viewui.vbs"


class CUI

    ' --------------------------------------------------------------------------
    ' Atributos Privadas
    private m_lPointer
    private m_oWorkspaceUI
    private m_oViewUI
    private m_oObjectUI
    private m_oParentUI


    private m_oObject           ' Suele ser una variable auxiliar.
                                ' La interfaces VUI solo
                                ' muestran los datos referentes
                                ' a un objeto. Este atributo indica
                                ' a que objeto pertenecen la propiedades
                                ' que se muestran.
                                ' Las interfaces FUI muestran todos
                                ' los objetos que se pueden vincular al
                                ' PTR de otro, el que se guarda en esta variable

	private m_oProperty			' Suele ser una variable auxiliar.
                                ' Las interfaces FUI muestran todos
                                ' los objetos que se pueden vincular al
                                ' PTR de otro, la que se guarda en esta variable
				


    private m_sName             ' Se crea un sName para identificar a
                                ' la UI sobre las otras.

    private sub m_SetMeInGlobal()
        call Global.UI_SetPointer(m_lPointer)
    end sub


    ' --------------------------------------------------------------------------
    ' Eventos
    public sub Class_Initialize()
        set m_oWorkspaceUI = new CWorkspaceUI
        set m_oViewUI = new CViewUI
    end sub

    public sub Class_Terminate()
        set m_oWorkspaceUI = nothing
        set m_oViewUI = nothing
    end sub


    ' --------------------------------------------------------------------------
    ' Propiedades Publicas
    public property get oWorkspaceUI()
        set oWorkspaceUI = m_oWorkspaceUI
    end property


    public property get oViewUI()
        set oViewUI = m_oViewUI
    end property


    public property get oObjectUI()
        set oObjectUI = m_oObjectUI
    end property


    public property get oParentUI()
        set oParentUI = m_oParentUI
    end property

    public property set oParentUI(byval o)
        set m_oParentUI = o
    end property


    public property get lPointer()
        lPointer = m_lPointer
    end property

    public property let lPointer(byval l)
        m_lPointer = l

        m_SetMeInGlobal

        m_oViewUI.lPointer = Global.UI_GetVUIlPointer
    end property


    public property get oObject()
        if isobject(m_oObject) then
            set oObject = m_oObject
        else
            set oObject = nothing
        end if
    end property

    public property set oObject(byval oNewObject)
        set m_oObject = oNewObject
    end property


    public property get oProperty()
        if isobject(m_oProperty) then
            set oProperty = m_oProperty
        else
            set oProperty = nothing
        end if
    end property

    public property set oProperty(byval oNewProperty)
        set m_oProperty = oNewProperty
    end property

    public property get sName()
        sName = m_sName
    end property

    public property let sName(sNewName)
        m_sName = sNewName
    end property


    ' --------------------------------------------------------------------------
    ' Metodos publicos
    public sub Show()
        dim lPointerBuffer0
        dim lPointerBuffer1
        dim lPointerBuffer2
        dim lPointerBuffer3

        ' Almaceno en buffer
        lPointerBuffer0 = Global.UI_GetPointer()
        lPointerBuffer1 = Global.WUI_GetPointer()
        lPointerBuffer2 = Global.VUI_GetPointer()

        ' Asigno los pointer de esta UI
        Global.UI_SetPointer me.lPointer
        Global.WUI_SetPointer me.oWorkspaceUI.lPointer
        Global.VUI_SetPointer me.oViewUI.lPointer

        ' Muestro la UI
        call Global.UI_Show()

        ' Reestablezco los lPointer
        Global.UI_SetPointer lPointerBuffer0
        Global.WUI_SetPointer lPointerBuffer1
        Global.VUI_SetPointer lPointerBuffer2

    end sub


    public sub OK()
        m_SetMeInGlobal
        
        Global.UI_OK
    end sub

    public sub Cancel()
        m_SetMeInGlobal

        Global.UI_Cancel
    end sub


    public sub Refresh()
        m_SetMeInGlobal
        Global.UI_Refresh
    end sub


	public sub Clear()
		' Elimino las clases
		do while me.oWorkspaceUI.RemoveClass(0)
		loop

		' Elimino los incoming works
		me.oWorkspaceUI.RemoveIncomingWorks
		
		' Elimino la vista actual
		me.oViewUI.RemoveAllItems
		me.oViewUI.iRowCount = 0
	
		' refresh
'		me.oViewUI.refresh
'		me.oWorkspaceUI.refresh
	end sub


    ' --------------------------------------------------------------------------
    ' Eventos
    public sub SetOnSelectItemEvent(byval sFunctionName)
        Global.UI_SetOnSelectItemEvent(sFunctionName)
    end sub

    public sub SetOnAceptEvent(byval sFunctionName)
        Global.UI_SetOnAceptEvent(sFunctionName)
    end sub

    public sub SetOnCancelEvent(byval sFunctionName)
        Global.UI_SetOnCancelEvent(sFunctionName)
    end sub

    public sub SetOnApplyEvent(byval sFunctionName)
        Global.UI_SetOnApplyEvent(sFunctionName)
    end sub

end class
